# -*- coding:UTF-8 -*-
import requests
from bs4 import BeautifulSoup
import time

if __name__ == '__main__':
    zaifenge=[]
    for i in range(1,3):
    #输入采集的页数
        print('正在采集第%s页' % (i))
        url="http://toutiao.sanhao.com/news-list.php?u=p%d" % (i)
        r=requests.get(url=url)
        html=r.text
        bf=BeautifulSoup(html,'lxml')
        jiegou=bf.find_all(class_='wx')
        bianhao=[]

        for each in jiegou:
            r=each.get('data-url')
            bianhao.append(r)
        for i in bianhao:
            fengge=i.split('-')
            shuzi=fengge[2].replace('.html',"")
            zaifenge.append(shuzi)
        time.sleep(1)

    for m in zaifenge:
        m=int(m)
        url="http://toutiao.sanhao.com/news-detail-%d.html" % (m)
        murl="http://m.sanhao.com/article.html?id=%d" % (m)
        print(url)
        print(murl)